

package com.hazelcast.test;

import com.hazelcast.logging.Logger;
import net.spy.memcached.MemcachedClient;

import javax.annotation.Nullable;

public final class MemcacheTestUtil {

    private MemcacheTestUtil() {
    }

    /**
     * Shutdowns {@link MemcachedClient} ignoring exceptions. Problems are just logged on FINE level. Workaround a
     * {@link java.util.ConcurrentModificationException} issue in Selector.shutdown() on IBM JDK.
     *
     * @param client a {@link MemcachedClient} to be shut down
     */
    public static void shutdownQuietly(@Nullable MemcachedClient client) {
        if (client == null) {
            return;
        }
        try {
            client.shutdown();
        } catch (Exception e) {
            Logger.getLogger(MemcacheTestUtil.class).fine("MemcachedClient.shutdown() failed. Ignoring.", e);
        }
    }
}
